package com.itheima.dubbo.mysql.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.commons.pojo.Announcement;
import com.itheima.dubbo.interfaces.AnnouncementApi;
import com.itheima.dubbo.mysql.mapper.AnnouncementUserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class AnnouncementApiImpl implements AnnouncementApi {

    @Autowired
    private AnnouncementUserMapper mapper;

    @Override
    public List<Announcement> findAnnouncementByPage(Integer page, Integer pagesize) {
        Page<Announcement> selectPage = mapper.selectPage(new Page<>(page, pagesize),
                Wrappers.lambdaQuery(Announcement.class).orderByDesc(Announcement::getCreated));
        return selectPage.getRecords();
    }
}
